<?php

    /**
    * Show top sentence 
    * for project Kurtulus Law
    * @author trungdt
    * @since Dec 2,
    * @copyright Absoft Viet Nam
    */
    if (!defined('EXPONENT')) exit('');
    global $sectionObj;
    global $db;
    $_page_title = _ab_layout_gettitle();
    
    $container_index_top_src = "";
    $__top_src = _ab_layout_get_topsentence_src();
    if ($__top_src != null)
    {
        $container_index_top_src = $__top_src;
    }
    else

        $container_index_top_src = "top_".$sectionObj->sef_name."_".$sectionObj->language."_";

    $_top_sentence=$db->selectObject("site_topsentence", "ref_location = '{$container_index_top_src}'");
    if (!isset($_top_sentence->id)) // not found
    {
        $_top_sentence->title="";
        $_top_sentence->content="";

        // try to reach the page title 
        if (strlen($_page_title) > 0)
        {
            $_top_sentence->title=$_page_title;
            // force id to force show
            $_top_sentence->id=" ";
        }
    } 
    
    if ($_top_sentence->title=="")
        $_top_sentence->title = $_page_title;
    
    // render
    if (isset($_top_sentence->id) || exponent_users_isAdmin())
    {
        $template = new template('topsentencemodule','_show',$loc);
        $template->assign('top_sentence',$_top_sentence);
        $template->register_permissions(
        array('administrate','edit'),$loc);
        $template->assign('ref_loc',$container_index_top_src);
        $template->output();
    }
?>